package database;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import model.Categoria;

public class CategoriaDAO extends DAOClass {

	@Override
	public Categoria getById(int id) {
		Categoria c = null;
		
		try{
			Connection conn = Conexao.getConexao();
			PreparedStatement pstm = conn.prepareStatement("select * from categoria where id = ?");
			pstm.setInt(1, id);
			
			ResultSet rs = pstm.executeQuery();
			if(rs.next())
				c = new Categoria(id, rs.getString("nome"));
			
			rs.close();
			pstm.close();
			conn.close();
		}
		catch(Exception e){
			e.printStackTrace();
		}
		return c;
	}

	@Override
	public <T> boolean inserir(T t) {
		return false;
	}

}
